
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>鸿蒙智能安防</title>
    <script src="https://cdn.tailwindcss.com/3.3.3"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css">
    <style>
        /* 全局样式 */
        body {
            font-family: 'HarmonyOS Sans', -apple-system, BlinkMacSystemFont, sans-serif;
            background-color: #f5f7fa;
            color: #333;
            transition: all 0.3s ease;
        }
        
        /* 自定义鸿蒙风格颜色 */
        :root {
            --primary-color: #007aff;
            --success-color: #07c160;
            --warning-color: #ff9500;
            --danger-color: #ff3b30;
            --text-primary: #333333;
            --text-secondary: #666666;
            --text-tertiary: #999999;
            --bg-color: #f5f7fa;
            --card-bg: #ffffff;
            --border-color: #e5e7eb;
        }
        
        /* 卡片样式 */
        .device-card {
            width: 90%;
            margin: 1rem auto;
            background-color: var(--card-bg);
            border-radius: 16px;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
            transition: all 0.3s ease;
            overflow: hidden;
            animation: fadeIn 0.5s ease-out;
        }
        
        .device-card:hover {
            transform: translateY(-4px);
            box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
        }
        
        /* 状态指示器 */
        .status-indicator {
            width: 10px;
            height: 10px;
            border-radius: 50%;
            display: inline-block;
            margin-right: 8px;
            transition: all 0.3s ease;
        }
        
        .status-normal {
            background-color: var(--success-color);
        }
        
        .status-warning {
            background-color: var(--warning-color);
        }
        
        .status-danger {
            background-color: var(--danger-color);
        }
        
        .status-off {
            background-color: var(--text-tertiary);
        }
        
        /* 底部导航栏 - 手机视图 */
        .bottom-nav {
            position: fixed;
            bottom: 0;
            left: 0;
            right: 0;
            height: 60px;
            background-color: var(--card-bg);
            border-top: 1px solid var(--border-color);
            display: flex;
            justify-content: space-around;
            align-items: center;
            z-index: 1000;
            box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
        }
        
        /* 左侧导航栏 - 平板/桌面视图 */
        .side-nav {
            position: fixed;
            top: 0;
            left: 0;
            bottom: 0;
            width: 80px;
            background-color: var(--card-bg);
            border-right: 1px solid var(--border-color);
            display: flex;
            flex-direction: column;
            align-items: center;
            padding-top: 2rem;
            z-index: 1000;
            box-shadow: 2px 0 10px rgba(0, 0, 0, 0.05);
        }
        
        /* 导航项样式 */
        .nav-item {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            padding: 1rem;
            color: var(--text-tertiary);
            transition: all 0.3s ease;
            cursor: pointer;
        }
        
        .nav-item.active {
            color: var(--primary-color);
        }
        
        .nav-item:hover {
            color: var(--primary-color);
        }
        
        /* 滑动动画 */
        .slide-in {
            animation: slideIn 0.3s ease forwards;
        }
        
        @keyframes slideIn {
            from {
                opacity: 0;
                transform: translateX(20px);
            }
            to {
                opacity: 1;
                transform: translateX(0);
            }
        }
        
        @keyframes fadeIn {
            from {
                opacity: 0;
                transform: translateY(10px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        
        /* 内容区域 */
        .content-area {
            transition: all 0.3s ease;
            min-height: 100vh;
            display: flex;
            flex-direction: column;
            justify-content: center;
        }
        
        /* 传感器信息项 */
        .sensor-item {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0.75rem 1rem;
            border-bottom: 1px solid var(--border-color);
            transition: all 0.2s ease;
        }
        
        .sensor-item:last-child {
            border-bottom: none;
        }
        
        .sensor-item:hover {
            background-color: rgba(0, 122, 255, 0.05);
        }
        
        .sensor-info {
            display: flex;
            align-items: center;
        }
        
        .sensor-icon {
            width: 32px;
            height: 32px;
            border-radius: 8px;
            background-color: rgba(0, 122, 255, 0.1);
            display: flex;
            align-items: center;
            justify-content: center;
            margin-right: 12px;
            color: var(--primary-color);
            transition: all 0.3s ease;
        }
        
        .sensor-item:hover .sensor-icon {
            background-color: rgba(0, 122, 255, 0.2);
            transform: scale(1.1);
        }
        
        /* 开关样式 */
        .toggle-switch {
            position: relative;
            display: inline-block;
            width: 44px;
            height: 24px;
        }
        
        .toggle-switch input {
            opacity: 0;
            width: 0;
            height: 0;
        }
        
        .toggle-slider {
            position: absolute;
            cursor: pointer;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-color: #ccc;
            transition: .4s;
            border-radius: 24px;
        }
        
        .toggle-slider:before {
            position: absolute;
            content: "";
            height: 18px;
            width: 18px;
            left: 3px;
            bottom: 3px;
            background-color: white;
            transition: .4s;
            border-radius: 50%;
        }
        
        input:checked + .toggle-slider {
            background-color: var(--primary-color);
        }
        
        input:checked + .toggle-slider:before {
            transform: translateX(20px);
        }
        
        /* 个人信息卡片 */
        .profile-card {
            max-width: 400px;
            margin: 2rem auto;
            padding: 2rem;
            background-color: var(--card-bg);
            border-radius: 16px;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
            text-align: center;
            animation: fadeIn 0.5s ease-out;
        }
        
        .avatar {
            width: 80px;
            height: 80px;
            border-radius: 50%;
            margin: 0 auto 1rem;
            background-color: rgba(0, 122, 255, 0.1);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 2rem;
            color: var(--primary-color);
        }
        
        /* 响应式布局 */
        @media (max-width: 767px) {
            .side-nav {
                display: none;
            }
            
            .content-area {
                padding-bottom: 70px;
            }
            
            .device-card {
                width: 80%;
                margin: 1rem auto;
            }
        }
        
        @media (min-width: 768px) {
            .bottom-nav {
                display: none;
            }
            
            .content-area {
                margin-left: 80px;
            }
            
            .device-card {
                width: 80%;
                max-width: 500px;
            }
        }
        
        /* 动画效果 */
        @keyframes pulse {
            0% {
                transform: scale(1);
            }
            50% {
                transform: scale(1.05);
            }
            100% {
                transform: scale(1);
            }
        }
        
        .animate-pulse {
            animation: pulse 2s infinite;
        }
        
        /* 手风琴效果 */
        .accordion-content {
            max-height: 0;
            overflow: hidden;
            transition: max-height 0.3s ease-out;
        }
        
        .accordion-content.active {
            max-height: 500px;
            transition: max-height 0.5s ease-in;
        }
        
        /* 卡片头部增强样式 */
        .card-header {
            position: relative;
            overflow: hidden;
        }
        
        .card-header::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: linear-gradient(135deg, var(--primary-color), #0056cc);
            opacity: 0.9;
            z-index: 1;
        }
        
        .card-header::after {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.3) 0%, transparent 60%);
            z-index: 2;
        }
        
        .card-header-content {
            position: relative;
            z-index: 3;
        }
        
        /* 渐变背景 */
        .bg-gradient-primary {
            background: linear-gradient(135deg, var(--primary-color), #0056cc);
        }
        
        .bg-gradient-secondary {
            background: linear-gradient(135deg, #5856d6, #3a3897);
        }
        
        /* 数值显示增强 */
        .value-display {
            font-size: 1.5rem;
            font-weight: 600;
            color: var(--primary-color);
            transition: all 0.3s ease;
        }
        
        .value-display.danger {
            color: var(--danger-color);
        }
        
        .value-display.warning {
            color: var(--warning-color);
        }
        
        /* 平滑滚动 */
        html {
            scroll-behavior: smooth;
        }
    </style>
</head>
<body>
    <!-- 底部导航栏 - 手机视图 -->
    <div class="bottom-nav">
        <div class="nav-item active" data-tab="home">
            <i class="fas fa-home text-xl"></i>
            <span class="text-xs mt-1">主页</span>
        </div>
        <div class="nav-item" data-tab="profile">
            <i class="fas fa-user text-xl"></i>
            <span class="text-xs mt-1">我的</span>
        </div>
    </div>
    
    <!-- 左侧导航栏 - 平板/桌面视图 -->
    <div class="side-nav">
        <div class="nav-item active" data-tab="home">
            <i class="fas fa-home text-xl"></i>
            <span class="text-xs mt-1">主页</span>
        </div>
        <div class="nav-item" data-tab="profile">
            <i class="fas fa-user text-xl"></i>
            <span class="text-xs mt-1">我的</span>
        </div>
    </div>
    
    <!-- 内容区域 -->
    <div class="content-area p-4">
        <!-- 主页内容 -->
        <div id="home-content" class="tab-content">
            <h1 class="text-2xl font-bold text-center mb-6">智能安防监控</h1>
            
            <!-- 人体感应模块 -->
            <div class="device-card mb-8">
                <div class="card-header bg-gradient-primary p-4 text-white">
                    <div class="card-header-content">
                        <div class="flex justify-between items-center">
                            <div class="flex items-center">
                                <i class="fas fa-user-friends text-xl mr-2"></i>
                                <h2 class="text-xl font-semibold">人体感应模块</h2>
                            </div>
                            <div class="flex items-center">
                                <span class="mr-2">正常</span>
                                <span class="status-indicator status-normal"></span>
                            </div>
                        </div>
                    </div>
                </div>
                
                <div class="accordion-content active">
                    <div class="sensor-item">
                        <div class="sensor-info">
                            <div class="sensor-icon">
                                <i class="fas fa-walking"></i>
                            </div>
                            <div>
                                <div class="font-medium">人体检测</div>
                                <div class="text-sm text-text-tertiary">当前状态</div>
                            </div>
                        </div>
                        <div class="flex items-center">
                            <span id="motion-status" class="mr-2">未检测到</span>
                            <span id="motion-indicator" class="status-indicator status-off"></span>
                        </div>
                    </div>
                    
                    <div class="sensor-item">
                        <div class="sensor-info">
                            <div class="sensor-icon">
                                <i class="fas fa-door-open"></i>
                            </div>
                            <div>
                                <div class="font-medium">门磁状态</div>
                                <div class="text-sm text-text-tertiary">门窗状态</div>
                            </div>
                        </div>
                        <div class="flex items-center">
                            <span id="door-status" class="mr-2">关闭</span>
                            <span id="door-indicator" class="status-indicator status-normal"></span>
                        </div>
                    </div>
                    
                    <div class="sensor-item">
                        <div class="sensor-info">
                            <div class="sensor-icon">
                                <i class="fas fa-lightbulb"></i>
                            </div>
                            <div>
                                <div class="font-medium">灯光状态</div>
                                <div class="text-sm text-text-tertiary">室内灯光</div>
                            </div>
                        </div>
                        <label class="toggle-switch">
                            <input type="checkbox" id="light-toggle">
                            <span class="toggle-slider"></span>
                        </label>
                    </div>
                    
                    <div class="sensor-item">
                        <div class="sensor-info">
                            <div class="sensor-icon">
                                <i class="fas fa-bell"></i>
                            </div>
                            <div>
                                <div class="font-medium">警报状态</div>
                                <div class="text-sm text-text-tertiary">安全警报</div>
                            </div>
                        </div>
                        <label class="toggle-switch">
                            <input type="checkbox" id="alarm-toggle" checked>
                            <span class="toggle-slider"></span>
                        </label>
                    </div>
                </div>
            </div>
            
            <!-- 烟雾传感器模块 -->
            <div class="device-card">
                <div class="card-header bg-gradient-secondary p-4 text-white">
                    <div class="card-header-content">
                        <div class="flex justify-between items-center">
                            <div class="flex items-center">
                                <i class="fas fa-smog text-xl mr-2"></i>
                                <h2 class="text-xl font-semibold">烟雾传感器模块</h2>
                            </div>
                            <div class="flex items-center">
                                <span id="smoke-module-status" class="mr-2">正常</span>
                                <span id="smoke-module-indicator" class="status-indicator status-normal"></span>
                            </div>
                        </div>
                    </div>
                </div>
                
                <div class="accordion-content active">
                    <div class="sensor-item">
                        <div class="sensor-info">
                            <div class="sensor-icon">
                                <i class="fas fa-cloud"></i>
                            </div>
                            <div>
                                <div class="font-medium">烟雾浓度</div>
                                <div class="text-sm text-text-tertiary">当前数值</div>
                            </div>
                        </div>
                        <div>
                            <span id="smoke-level" class="value-display">9.4</span>
                            <span class="text-sm text-text-tertiary ml-1">ppm</span>
                        </div>
                    </div>
                    
                    <div class="sensor-item">
                        <div class="sensor-info">
                            <div class="sensor-icon">
                                <i class="fas fa-temperature-high"></i>
                            </div>
                            <div>
                                <div class="font-medium">环境温度</div>
                                <div class="text-sm text-text-tertiary">当前温度</div>
                            </div>
                        </div>
                        <div>
                            <span id="temperature" class="value-display">25</span>
                            <span class="text-sm text-text-tertiary ml-1">°C</span>
                        </div>
                    </div>
                    
                    <div class="sensor-item">
                        <div class="sensor-info">
                            <div class="sensor-icon">
                                <i class="fas fa-tint"></i>
                            </div>
                            <div>
                                <div class="font-medium">环境湿度</div>
                                <div class="text-sm text-text-tertiary">当前湿度</div>
                            </div>
                        </div>
                        <div>
                            <span id="humidity" class="value-display">45</span>
                            <span class="text-sm text-text-tertiary ml-1">%</span>
                        </div>
                    </div>
                    
                    <div class="sensor-item">
                        <div class="sensor-info">
                            <div class="sensor-icon">
                                <i class="fas fa-volume-up"></i>
                            </div>
                            <div>
                                <div class="font-medium">蜂鸣器状态</div>
                                <div class="text-sm text-text-tertiary">声音警报</div>
                            </div>
                        </div>
                        <label class="toggle-switch">
                            <input type="checkbox" id="buzzer-toggle" checked>
                            <span class="toggle-slider"></span>
                        </label>
                    </div>
                </div>
            </div>
        </div>
        
        <!-- 我的页面内容 -->
        <div id="profile-content" class="tab-content hidden">
            <h1 class="text-2xl font-bold text-center mb-6">个人中心</h1>
            
            <!-- 个人信息卡片 -->
            <div class="profile-card">
                <div class="avatar">
                    <i class="fas fa-user"></i>
                </div>
                <h2 class="text-xl font-semibold mb-1">管理员</h2>
                <p class="text-text-tertiary mb-4">admin@example.com</p>
                
                <div class="text-left mb-4">
                    <div class="mb-2">
                        <div class="text-sm text-text-tertiary">设备数量</div>
                        <div class="font-medium">6台</div>
                    </div>
                    <div class="mb-2">
                        <div class="text-sm text-text-tertiary">安全等级</div>
                        <div class="font-medium">高级</div>
                    </div>
                    <div>
                        <div class="text-sm text-text-tertiary">上次登录</div>
                        <div class="font-medium">2023-06-15 14:30</div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    
    <script>
        // 初始化页面
        document.addEventListener('DOMContentLoaded', function() {
            // 获取DOM元素
            const navItems = document.querySelectorAll('.nav-item');
            const tabContents = document.querySelectorAll('.tab-content');
            const deviceCards = document.querySelectorAll('.device-card');
            
            // Tab切换功能
            navItems.forEach(item => {
                item.addEventListener('click', function() {
                    // 移除所有active类
                    navItems.forEach(navItem => navItem.classList.remove('active'));
                    tabContents.forEach(content => content.classList.add('hidden'));
                    
                    // 添加当前active类
                    this.classList.add('active');
                    const tabId = this.getAttribute('data-tab');
                    const activeContent = document.getElementById(`${tabId}-content`);
                    activeContent.classList.remove('hidden');
                    
                    // 添加动画效果
                    activeContent.classList.add('slide-in');
                    setTimeout(() => {
                        activeContent.classList.remove('slide-in');
                    }, 300);
                });
            });
            
            // 模拟传感器数据更新
            function updateSensorData() {
                // 人体检测状态
                const motionDetected = Math.random() > 0.8;
                const motionStatus = document.getElementById('motion-status');
                const motionIndicator = document.getElementById('motion-indicator');
                
                if (motionStatus && motionIndicator) {
                    if (motionDetected) {
                        motionStatus.textContent = '已检测到';
                        motionIndicator.classList.remove('status-off');
                        motionIndicator.classList.add('status-warning', 'animate-pulse');
                    } else {
                        motionStatus.textContent = '未检测到';
                        motionIndicator.classList.remove('status-warning', 'animate-pulse');
                        motionIndicator.classList.add('status-off');
                    }
                }
                
                // 门磁状态
                const doorOpen = Math.random() > 0.9;
                const doorStatus = document.getElementById('door-status');
                const doorIndicator = document.getElementById('door-indicator');
                
                if (doorStatus && doorIndicator) {
                    if (doorOpen) {
                        doorStatus.textContent = '开启';
                        doorIndicator.classList.remove('status-normal');
                        doorIndicator.classList.add('status-warning', 'animate-pulse');
                    } else {
                        doorStatus.textContent = '关闭';
                        doorIndicator.classList.remove('status-warning', 'animate-pulse');
                        doorIndicator.classList.add('status-normal');
                    }
                }
                
                // 烟雾浓度 (固定为9.4ppm)
                const smokeLevel = document.getElementById('smoke-level');
                if (smokeLevel) {
                    smokeLevel.textContent = '9.4';
                    
                    // 根据烟雾浓度更新状态指示器
                    const smokeModuleStatus = document.getElementById('smoke-module-status');
                    const smokeModuleIndicator = document.getElementById('smoke-module-indicator');
                    
                    if (smokeModuleStatus && smokeModuleIndicator) {
                        smokeModuleStatus.textContent = '正常';
                        smokeModuleIndicator.classList.remove('status-warning', 'status-danger', 'animate-pulse');
                        smokeModuleIndicator.classList.add('status-normal');
                        smokeLevel.classList.remove('warning', 'danger');
                    }
                }
                
                // 随机更新温度
                const temperature = Math.floor(Math.random() * 10) + 22;
                const tempElement = document.getElementById('temperature');
                if (tempElement) {
                    tempElement.textContent = temperature;
                }
                
                // 随机更新湿度
                const humidity = Math.floor(Math.random() * 20) + 40;
                const humidityElement = document.getElementById('humidity');
                if (humidityElement) {
                    humidityElement.textContent = humidity;
                }
            }
            
            // 定期更新传感器数据
            setInterval(updateSensorData, 5000);
            
            // 初始化传感器数据
            updateSensorData();
            
            // 开关切换事件
            document.getElementById('light-toggle').addEventListener('change', function() {
                // 这里可以添加实际的控制逻辑
                console.log('灯光状态已切换为:', this.checked ? '开启' : '关闭');
            });
            
            document.getElementById('alarm-toggle').addEventListener('change', function() {
                // 这里可以添加实际的控制逻辑
                console.log('警报状态已切换为:', this.checked ? '开启' : '关闭');
            });
            
            document.getElementById('buzzer-toggle').addEventListener('change', function() {
                // 这里可以添加实际的控制逻辑
                console.log('蜂鸣器状态已切换为:', this.checked ? '开启' : '关闭');
            });
            
            // 为卡片添加点击展开/折叠功能
            deviceCards.forEach(card => {
                const header = card.querySelector('.card-header');
                const content = card.querySelector('.accordion-content');
                
                if (header && content) {
                    header.addEventListener('click', function() {
                        content.classList.toggle('active');
                    });
                }
            });
        });
    </script>
</body>
</html>
